﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Agenda.Master" AutoEventWireup="true"
    CodeBehind="Atendimento.aspx.cs" Inherits=" RzCorportativo.Views.Farmacia.Atendimento" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div style="background-color: #fafafa; padding: 8px">
        <div id="navbarExample" class="navbar navbar-static" style="margin-bottom: 0px">
            <div class="navbar-inner">
                <div class="container" style="width: auto;">
                    <a class="brand" href="#">Atendimento</a>
                    <ul class="nav">
                        <li class="active"><a href="#fat">
                            <%--@fat--%></a></li>
                        <li class=""><a href="#mdo">
                            <%--@mdo--%></a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div data-spy="scroll" data-target="" data-offset="0" class="scrollspy-example">
            <div style="overflow: auto; height: 500px; background-color: White">
                <div class="tabbable tabs-left">
                </div>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="LeftContent" runat="server">
<script src="<%=this.ResolveUrl("~/Recursos/j/eComplete.js")%>" type="text/javascript"></script>
    <asp:HiddenField runat="server" ID="PacienteId" />
    <asp:HiddenField runat="server" ID="TipoMedicamentoId" />
    <div class="controls controls-row">
        <asp:TextBox runat="server" ID="Cpf" placeholder="CPF" data-toggle="tooltip" mask="cpf"
            title="CPF do paciente" data-placement="left" name="complete" value="" auto-complete="true"
            eid="cpf" requesttype="post" contenttype="application/json; charset=utf-8" isasync="true"
            length="1" datatype="json" templeted="true" onrender="getItemPaciente" onerror="getErrorPaciente"
            onselected="selectedItemPaciente" />
    </div>
    <div class="controls controls-row">
        <asp:TextBox runat="server" ID="TipoMedicamento" placeholder="Medicamento"
            data-toggle="tooltip" title="Nome do medicamento" data-placement="left" name="complete"
            value="" auto-complete="true" eid="medicamento" requesttype="post" contenttype="application/json; charset=utf-8"
            isasync="true" length="1" datatype="json" templeted="true" onrender="getItemMedicamento"
            onerror="getErrorMedicamento" onselected="selectedItemMedicamento" />
    </div>
    <div class="controls controls-row">
        <asp:TextBox runat="server" ID="Quantidade" placeholder="Quantidade" data-toggle="tooltip" title="Quantidade" data-placement="left" mask="decimal" />
    </div>
    <script type="text/javascript">
        function Back() {
            window.location.href = '<%=this.ResolveUrl("~/Views/Farmacia/Atendimento.aspx")%>';
            return false;
        }
        /************************************************ PACIENTE **************************************************************/
        function getItemPaciente(ul, item) {

            var inner_html = '<a><div class="list_item_container"><div class=""><strong>Nome:</strong> ' +
                            item.Nome + '</div><div class="description"><strong>CPF: </strong>' +
                            item.Cpf + '</div></div></a>';
            return $("<li style='width:350px'></li>")
            .data("item.autocomplete", item)
            .append(inner_html)
            .appendTo(ul);
        }
        function getErrorPaciente(e) {
            var _alert = new Alert();
            _alert.Name = "erroGeral";
            _alert.Type = AlertType.Error;
            _alert.AddMessage(e.d ? e.d : e.responseText);
            _alert.Show();
        }
        function selectedItemPaciente(event, ui, context) {
            var item = ui.item && ui.item.value ? ui.item : context;
            if (item.PacienteId) {
                $("input[id$='PacienteId']").val(item.PacienteId.toString(10))
            }
        }

        /************************************************ MEDICAMENTO **************************************************************/
        function getItemMedicamento(ul, item) {

            var inner_html = '<a><div class="list_item_container"><div class=""><strong>Nome:</strong> ' +
                            item.Descricao + '</div>';
            return $("<li style='width:350px'></li>")
            .data("item.autocomplete", item)
            .append(inner_html)
            .appendTo(ul);
        }
        function getErrorMedicamento(e) {
            var _alert = new Alert();
            _alert.Name = "erroGeral";
            _alert.Type = AlertType.Error;
            _alert.AddMessage(e.d ? e.d : e.responseText);
            _alert.Show();
        }

        function selectedItemMedicamento(event, ui, context) {
            var item = ui.item && ui.item.value ? ui.item : context;
            if (item.TipoMedicamentoId) {
                $("input[id$='TipoMedicamentoId']").val(item.TipoMedicamentoId.toString(10))
            }
        }
    </script>
</asp:Content>
